/**
 * Created by Flyforwards on 2017/8/1.
 */

import React, { Component } from "react"
import  { Link, browserHistory } from 'react-router'
import fetchData from '../../util/fetch'
import {Row,Col} from 'antd'
var ReactDOM = require("react-dom");
class EnvironmentIntroduce extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            title: "服务",
            homelist: [],
            banner: null,
            landScape: null,//园林景观
            motherCare: null,//妈妈养护
            babyCare: null,//宝宝养护
            motherRecovery: null//产后康复

        }
    }


    getData(url, opts) {
        fetchData(url, opts, function (res) {
            let data = eval(res.data)
            switch (opts.str) {
                case '2-16':
                    this.setState({
                        landScape: data
                    });
                    break;
                case '2-17':
                    this.setState({
                        motherCare: data
                    });
                    break;
                case '2-18':
                    this.setState({
                        babyCare: data
                    });
                    break;
                case '2-19':
                    this.setState({
                        motherRecovery: data
                    });
                    break;
            }
        }.bind(this))
    }


    getBannerData(url, opts) {
        fetchData(url, opts, function (res) {
            let data = eval(res.data);
            this.setState({
                banner: data
            });
        }.bind(this));
    }

    componentWillMount() {
        //banner类型 1首页、2hibaby服务、3美研中心、4活动咨询、5新妈分享、6关于Hibaby
        this.getBannerData('/crm/api/v1/web/banner/findOneByType', { "dataId": 24 });
        //2-16	园林景观 view
        this.getData('/crm/api/v1/web/news/findOneByType', { "str": "2-16" });
        //2-17	妈妈养护 motherCare
        this.getData('/crm/api/v1/web/news/findOneByType', { "str": "2-17" });
        // 2-18	宝宝养护
        this.getData('/crm/api/v1/web/news/findOneByType', { "str": "2-18" });
        // 2-19	产后康复
        this.getData('/crm/api/v1/web/news/findOneByType', { "str": "2-19" });
    }

    render() {
        //console.log(this.state.expertTeam.content)
        // if (this.state.expertTeam && $(".expertTeam-div p").nextAll().length === 0) {
        //     $(".expertTeam-div-content").html(this.state.expertTeam.content);
        // }
        // if (this.state.infantAndMomNurseTeam && $(".infantAndMomNurseTeam-div p").nextAll().length === 0) {
        //     $(".infantAndMomNurseTeam-div").append(this.state.infantAndMomNurseTeam.content);
        // }
        // if (this.state.nurseTeam && $(".nurseTeam-div p").nextAll().length === 0) {
        //     $(".nurseTeam-div").append(this.state.nurseTeam.content);
        // }
        // if (this.state.servicesTeam && $(".servicesTeam-div p").nextAll().length === 0) {
        //     $(".servicesTeam-div").append(this.state.servicesTeam.content);
        // }
        return (
            <div className="environment-introduce">
                {/*banner*/}
                <div className="service-banner"><img src={this.state.banner ? this.state.banner.imgUrl : null}/></div>
                <div className="content environment">
                    {/*园林景观*/}

                    <div className="land-scape">
                        <Row className="landScape_top">
                            <Col span={12} className="landScape_img">
                                <img src={this.state.landScape ? this.state.landScape.img1Url : null}/>
                            </Col>
                            <Col span={12}className="landScape_content">
                                <h3>{this.state.landScape ? this.state.landScape.title : null}</h3>
                                <div className="landScape_summary" style={{fontSize:'18px'}}>{this.state.landScape ? this.state.landScape.summary : null}</div>
                                <span className="landScape_border"></span>
                                <div className="land_content" dangerouslySetInnerHTML={{ __html:this.state.landScape ? this.state.landScape.content : null }}>
                                </div>
                            </Col>
                        </Row>
                        <div className="landScape_bottom">
                            <img src={this.state.landScape ? this.state.landScape.img2Url : null}/>
                        </div>
                    </div>
                    {/*妈妈修养*/}
                    <div className="land-scape mother-care">
                        <Row className="landScape_top motherCare_top">
                            <Col span={12} className="landScape_img">
                                <img src={this.state.motherCare ? this.state.motherCare.img1Url : null}/>
                            </Col>
                            <Col span={12}className="landScape_content">
                                <h3>{this.state.motherCare ? this.state.motherCare.title : null}</h3>
                                <div className="landScape_summary" style={{fontSize:'18px'}}>{this.state.motherCare ? this.state.motherCare.summary : null}</div>
                                <span className="landScape_border"></span>
                                <div className="land_content" dangerouslySetInnerHTML={{ __html:this.state.motherCare ? this.state.motherCare.content : null }}>
                                </div>
                            </Col>
                        </Row>
                        <div className="landScape_bottom">
                            <img src={this.state.motherCare ? this.state.motherCare.img2Url : null}/>
                        </div>
                    </div>

                    {/*宝宝养护*/}
                    <div className="land-scape">
                        <Row className="landScape_top">
                            <Col span={12} className="landScape_img">
                                <img src={this.state.babyCare ? this.state.babyCare.img1Url : null}/>
                            </Col>
                            <Col span={12}className="landScape_content">
                                <h3>{this.state.babyCare ? this.state.babyCare.title : null}</h3>
                                <div className="landScape_summary" style={{fontSize:'14px'}}>{this.state.babyCare ? this.state.babyCare.summary : null}</div>
                                <span className="landScape_border"></span>
                                <div className="land_content" dangerouslySetInnerHTML={{ __html:this.state.babyCare ? this.state.babyCare.content : null }}>
                                </div>
                            </Col>
                        </Row>
                        <div className="landScape_bottom">
                            <img src={this.state.babyCare ? this.state.babyCare.img2Url : null}/>
                        </div>
                    </div>
                    {/*产后恢复*/}
                    <div className="land-scape mother-care">
                        <Row className="landScape_top motherCare_top">
                            <Col span={12} className="landScape_img">
                                <img src={this.state.motherRecovery ? this.state.motherRecovery.img1Url : null}/>
                            </Col>
                            <Col span={12}className="landScape_content">
                                <h3>{this.state.motherRecovery ? this.state.motherRecovery.title : null}</h3>
                                <div className="landScape_summary" style={{fontSize:'18px'}}>{this.state.motherRecovery ? this.state.motherRecovery.summary : null}</div>
                                <span className="landScape_border"></span>
                                <div className="land_content" dangerouslySetInnerHTML={{ __html:this.state.motherRecovery ? this.state.motherRecovery.content : null }}>
                                </div>
                            </Col>
                        </Row>
                        <div className="landScape_bottom">
                            <img src={this.state.motherRecovery ? this.state.motherRecovery.img2Url : null}/>
                        </div>
                    </div>
                </div>
            </div>
        )
    }
}
export default EnvironmentIntroduce;
